//
//  UIBarButtonItem-Extension.swift
//  Stauts
//
//  Created by Kylin on 16/3/13.
//  Copyright © 2016年 Kylin. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    convenience init(imageName : String ,taget : AnyObject?, action : Selector){
        
        let button = UIButton(type: .Custom)
        
        button.setImage(UIImage(named: imageName), forState: .Normal)
        button.setImage(UIImage(named: imageName + "_highlighted"), forState: .Highlighted)
        button.sizeToFit()
        button.addTarget(taget, action: action, forControlEvents: .TouchUpInside)
        
        // 设置BarButtomItem的view为一个自定义的按钮
        self.init(customView : button)
    }
}
